<?php
class IdentifyCode 
{
	
	public function __construct()
	{
	}
	public function createRandCode($len)
	{
		//0
		$numberArr = array(48,49,50,51,52,53,54,55,56,57);
		//1
		$lowerAlphabet = array(97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122);
		//2
		$upperAlphabet = array(65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90);
		
		$randString="";
		
		for($i=0;$i<$len;$i++)
		{
			$rand="";
			
			$num=mt_rand(0, 2);
			switch ($num)
			{
				case 0:
					$rand = chr($numberArr[mt_rand(0, count($numberArr)-1)]);
					break;
				case 1:
					$rand = chr($lowerAlphabet[mt_rand(0, count($lowerAlphabet)-1)]);
					break;
				case 2:
					$rand = chr($upperAlphabet[mt_rand(0, count($upperAlphabet)-1)]);
					break;
				default:
					$rand = chr($lowerAlphabet[mt_rand(0, count($lowerAlphabet)-1)]);
					break;
			}
			$randString=$randString.$rand;
		}
		return $randString;
	}
	
	public function createNumberCode($len)
	{
		//0
		$numberArr = array(48,49,50,51,52,53,54,55,56,57);
		
		$randString="";
		
		for($i=0;$i<$len;$i++)
		{
			$rand="";
			$in=mt_rand(0, count($numberArr)-1);
			$rand = chr($numberArr[$in]);
			$randString=$randString.$rand;
		}
		return $randString;
	}
	
	public function createLowcharCode($len)
	{
		//1
		$lowerAlphabet =  array(97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122);
		
		$randString="";
		
		for($i=0;$i<$len;$i++)
		{
			$rand="";
			$rand = chr($lowerAlphabet[mt_rand(0, count($lowerAlphabet)-1)]);
			$randString=$randString.$rand;
		}
		return $randString;
	}
	
	public function createUpcharCode($len)
	{
		//2
		$upperAlphabet =array(65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90);
		
		$randString="";
		
		for($i=0;$i<$len;$i++)
		{
			$rand="";
			$rand = chr($upperAlphabet[mt_rand(0, count($upperAlphabet)-1)]);
			$randString=$randString.$rand;
		}
		return $randString;
	}
}

?>